//
//  UITableView+CachHeight.m
//  lvfj
//
//  Created by lvfeijun on 2021/6/3.
//  Copyright © 2021 Goudu KuaiEx Technology(Shenzhen)Co.,ltd. All rights reserved.
//

#import "UITableView+CachHeight.h"
#import <UITableView+FDTemplateLayoutCell.h>
//pod 'UITableView+FDTemplateLayoutCell'
@implementation UITableView (CachHeight)
/*
 @interface FDKeyedHeightCache : NSObject

 //判断缓存中是否存在key为值的缓存高度
 - (BOOL)existsHeightForKey:(id<NSCopying>)key;

 //对指定key的cell设置高度为height
 - (void)cacheHeight:(CGFloat)height byKey:(id<NSCopying>)key;

 //从缓存中获取对应key的cell的高度height值
 - (CGFloat)heightForKey:(id<NSCopying>)key;

 //从缓存中删除指定key的cell的值
 - (void)invalidateHeightForKey:(id<NSCopying>)key;

 //移除缓存中所有的cell的高度缓存值
 - (void)invalidateAllHeightCache;
 @end
 */
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    //删除缓存
    if (indexPath.section==1) {
        [tableView.fd_indexPathHeightCache invalidateHeightAtIndexPath:indexPath];
    }
    return [tableView fd_heightForCellWithIdentifier:kHQNewFavoriteCell1ID cacheByKey:indexPath configuration:^(HQNewFavoriteCell1 *cell) {
        if (indexPath.section%2) {
            [cell setData];
        }
    }];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kHQNewFavoriteCell1ID];
    if (indexPath.section%2) {
        [cell setData];
    }
//    [self configurationCell:cell indexPath:indexPath];
    return cell;
}


@end
